<template>
	<view >
		<image class="photo"  :src="MyPhoto" @click="changepic()"></image>
		<view>
			<view class="userinfo">
				<view class="item" >
					<view class="info_border">
					<text>用户名</text>
					<view class="name">{{GetAllUserInfo.username}}</view>
					<view style="margin-left: 20px;" @click="change_info(1, $event)">></view>
					</view>
					<view class="text_line"></view>
				</view>
			</view>
			<view class="userinfo">
				<view class="item" >
					<view class="info_border">
					<text>电话</text>
					<view class="name">{{GetAllUserInfo.tele}}</view>
					<view style="margin-left: 20px;" @click="change_info(2, $event)">></view>
					</view>
					<view class="text_line"></view>
				</view>
			</view>
			<view class="userinfo">
				<view class="item" >
					<view class="info_border">
					<text>性别</text>
					<view class="name">{{gender}}</view>
					<view style="margin-left: 20px;" @click="change_info(3, $event)">></view>
					</view>
					<view class="text_line"></view>
				</view>
			</view>
			<view class="userinfo">
				<view class="item" >
					<view class="info_border">
					<text>密码</text>
					<view class="name">{{GetAllUserInfo.password}}</view>
					<view style="margin-left: 20px;" @click="change_info(4, $event)">></view>
					</view>
					<view class="text_line"></view>
				</view>
			</view>
			
		</view>
			
		</view>
	</view>

</template>

<script>
	export default {
	  data() {
	    return {
			MyPhoto:"",
			gender:"男",
			GetAllUserInfo:{},
	        formData: { // 表单数据对象
	        "name": '',
	        "email": '',
			"phone":'',
			"birthday":'',
			"address":''
	        // 其他字段...
	      },
		    user_info:{
			  "token":'',
		  }
	    };
	  },
	  onLoad:function(){
		  let new_url;
		  if(uni.getStorageSync('login-role')==1)
		  new_url='http://192.168.2.226:8086/business/user/getinfo';
		  else
		  new_url='http://192.168.2.226:8086/business/seller/getinfo';
		  
	  	  this.get_user_info(new_url);
		  
	  },
	  methods: {
	    submitForm() {
	
	    },
		change_info(infoType, event){
			    this.$router.push({
			      path: '/pages/setting/change_info',
			      query: { type: infoType } // 将infoType作为查询参数传递
			    });	
		},
		get_user_info(new_url){
			this.user_info.token=uni.getStorageSync('login-user').token;
			console.log(this.user_info.token);
			uni.request({
			 	url:new_url,
			 	method:'GET',
				header: {
				        'token': this.user_info.token // 在这里设置请求头
				    },
				
			 	// 返回成功的结果
			 	success:(res) =>{
				console.log(res.data.data);
				this.GetAllUserInfo = res.data.data;
				uni.setStorageSync('UserInfo',res.data.data);
				console.log(this.GetAllUserInfo.username);
				
				if(this.GetAllUserInfo.gender==1)
				this.gender='女';
				let MyPhoto=res.data.data.photo;
				this.MyPhoto='http://192.168.2.226:8086/business/common2/download?name='+encodeURIComponent(MyPhoto) ;
				
				},
			 	fail:(error) => {
			 		console.log("获取失败")
			 	},
			 })
			
		},
		changepic(){
			uni.navigateTo({
				url:'/pages/tool/more'
			})
		}
		
	  }
	};
</script>

<style>
	.photo{
		left: 127px;
		top: 20px;
		width: 120px;
		height: 120px;
		
	}
	
	.userinfo {
		background-color: srgba(85, 255, 0, 0.0);
		padding: 5px 0;
		margin-top: 15px;
		
	}
	
	.userinfo .item {
		height: 40px;
		line-height: 60px;
		padding: 0 20px;
		display: flex;
		flex-direction: column;
	}
	
	.text_line{
			  
			/*
			盒子下边距，这里用来指定下划线距离文字的高度*/
			padding-bottom: 1px;
			
			/*设定一个2px，实线*/
	  border-bottom: 2px solid rgba(245,245,245,1); 
	}
	.text_line1{
			  
			/*
			盒子下边距，这里用来指定下划线距离文字的高度*/
			padding-bottom: 1px;
			
			/*设定一个2px，实线*/
	  border-bottom: 2px solid rgba(245,245,245,1); 
	}
	
	.info_border{
		display: flex;
		flex-direction: row;
		width: 100%;
	}
	.info_border text{
		
		width: 70px;
	}
	
	.name{
		margin-left: 130px;
		width: 100px;
		position: relative;
	}
	
	  .form-container {
	    /* 表单的样式 */
		height: 150px;
		margin-top: 40%;
		margin-left: 20%;
	    position: absolute;
	    top: 0;
	    left: 0;
	    z-index: 10;
	    background-color: rgba(255, 255, 255, 0.9);
	    padding: 20px;
	    border: 1px solid #8a8a8a;
	    /* 其他您需要的样式 */
	  }

	
	
</style>